<template>
  <div id="member_content">
    <div class="header">
      <el-row type="flex">
        <el-row type="flex">
          <el-input
            v-model="queryList.keyword"
            size="small"
            clearable
            placeholder="会员名称/等级"
          />
          <el-button
            class="searchBtn"
            size="small"
            type="primary"
            @click="handleSearch"
          >搜索</el-button>
          <!-- <el-button class="addTeachBtn" size="small" type="primary" @click="addMemberLevel">添加会员等级</el-button> -->
          <el-button
            class="addTeachBtn"
            size="small"
            type="primary"
            @click="isShowAddMemberLevelDialog = true"
          >添加会员等级</el-button>
        </el-row>
      </el-row>
    </div>
    <el-table
      :data="memberLevelList"
      border
      fit
      highlight-current-row
      style="width: 100%"
      :element-loading-text="g.loadingStr"
      :header-cell-style="{ background: g.mainColor }"
    >
      <el-table-column label="序号" align="center" fixed>
        <!-- <template slot-scope="{ $index }">
          <span>{{ $index + 1 }}</span>
        </template> -->
        <!-- <template slot-scope="{ row }"> -->
        <template>
          <span />
        </template>
      </el-table-column>
      <el-table-column label="会员名称" align="center">
        <template>
          <span />
        </template>
      </el-table-column>
      <el-table-column label="会员等级" align="center">
        <template>
          <span />
        </template>
      </el-table-column>
      <el-table-column label="功能权限" align="center">
        <template>
          <span />
        </template>
      </el-table-column>
      <el-table-column label="售价" align="center">
        <template>
          <span />
        </template>
      </el-table-column>
      <el-table-column label="使用时长" align="center">
        <template>
          <span />
        </template>
      </el-table-column>
      <el-table-column label="状态" align="center">
        <template>
          <span />
        </template>
      </el-table-column>
      <el-table-column label="操作" align="center">
        <template>
          <el-button type="primary">下架</el-button>
          <el-button type="success">编辑</el-button>
          <el-button type="danger">删除</el-button>
        </template>
      </el-table-column>
    </el-table>
    <el-dialog
      title="添加会员等级"
      :visible.sync="isShowAddMemberLevelDialog"
      min-width="800px"
    >
      <el-form
        ref="ruleForm"
        :model="ruleForm"
        :rules="rules"
        label-width="130px"
        class="form_style"
      >
        <el-form-item label="会员名字" prop="name">
          <el-input v-model="ruleForm.name" />
        </el-form-item>
        <el-form-item label="会员等级" prop="region">
          <el-select v-model="ruleForm.region" placeholder="请选择会员等级">
            <el-option label="1级" value="1" />
            <el-option label="2级" value="2" />
          </el-select>
        </el-form-item>
        <el-form-item label="使用时长" prop="region">
          <el-select v-model="ruleForm.region" placeholder="请选择使用时长">
            <el-option label="1年" value="1" />
            <el-option label="2年" value="2" />
          </el-select>
        </el-form-item>
        <el-form-item label="会员价格" prop="name">
          <el-input v-model="ruleForm.name" />
        </el-form-item>
        <el-form-item label="邀请投递" prop="name">
          <el-input v-model="ruleForm.name" />
        </el-form-item>
        <el-form-item label="急聘设置" prop="name">
          <el-input v-model="ruleForm.name" />
        </el-form-item>
        <el-form-item label="职位上限" prop="name">
          <el-input v-model="ruleForm.name" />
        </el-form-item>
        <el-form-item label="Banner广告服务" prop="region">
          <el-select v-model="ruleForm.region" placeholder="请选择使用时长">
            <el-option label="1天" value="1" />
            <el-option label="2天" value="2" />
          </el-select>
        </el-form-item>
        <el-form-item label="子账号" prop="name">
          <el-input v-model="ruleForm.name" />
        </el-form-item>
        <el-form-item>
          <el-button
            type="primary"
            @click="submitForm('ruleForm')"
          >确定</el-button>
          <el-button
            @click="isShowAddMemberLevelDialog = false"
          >取消</el-button>
        </el-form-item>
      </el-form>
    </el-dialog>
    <pagination
      v-show="total > 0"
      :total="total"
      :page.sync="queryList.currentPage"
      :limit.sync="queryList.pageSize"
      @pagination="getList"
    />
  </div>
</template>

<script>
import Pagination from '@/components/Pagination'
export default {
  components: { Pagination },
  data() {
    return {
      memberLevelList: null,
      isShowAddMemberLevelDialog: false,
      total: 1,
      queryList: {
        keyword: '',
        currentPage: 1,
        pageSize: 10
      },
      ruleForm: {
        name: '',
        region: ''
      },
      rules: {
        name: [{ required: true, message: '请输入活动名称', trigger: 'blur' }, { min: 3, max: 5, message: '长度在 3 到 5 个字符', trigger: 'blur' }],
        region: [{ required: true, message: '请选择活动区域', trigger: 'change' }]
      }
    }
  },
  methods: {
    getList() { },
    handleSearch() { },
    getMemberList() { },
    addMemberLevel() { },
    submitForm(formName) {
      this.$refs[formName].validate((valid) => {
        if (valid) {
          alert('submit!')
        } else {
          console.log('error submit!!')
          return false
        }
      })
    },
    resetForm(formName) {
      this.$refs[formName].resetFields()
    }
  }
}
</script>

<style scoped lang='scss'>
#member_content {
  padding: 15px;
  .header {
    margin-bottom: 15px;
    .searchBtn {
      margin-left: 15px;
    }
  }
  .form_style {
    margin-right: 50px;
  }
}
</style>
